<template>
    <div class="form-group">
        <label class="col-sm-4 control-label">
            <i class="colorRed" v-if="this.$route.path !='/cars/carsmanage'">*</i> 使用部门：</label>
        <div class="col-sm-8">
            <select class="form-control select2" style="width: 100%;" @change="$emit('input', $event.target.value)" v-model="deptID">
                <option value="" disabled selected style='display:none;'>请选择</option>
                <option v-for="item in deptlistData" :key="item.value" :value="item.deptId">{{item.name}}</option>
            </select>
        </div>
    </div>
</template>

<script>
export default {
    props: ["msg"],

    data() {
        return {
            deptID: "",
            deptlistData: []
        };
    },
    mounted() {
        this.getDeptlist();
    },
    methods: {
        getDeptlist() {
            this.$api.cars.home.deptlist().then(res => {
                if (res.success) {
                    // console.log(res)
                    this.deptlistData = res.data[0].childsList;
                }
            });
        }
    },
    watch: {
        msg() {
            this.deptID = this.msg;
        }
    }
};
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
.control-label {
    padding: 0;
    line-height: 34px;
    text-align: right;
}
input,
select,
textarea {
    border-radius: 5px;
}
</style>
